package com.xy.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author xy
 */
public class ServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //向管道加入处理器
        ChannelPipeline channelPipeline = socketChannel.pipeline();
        //添加http编码解码器
        channelPipeline.addLast("myHttpServerCodec", new HttpServerCodec());
        channelPipeline.addLast("myHttpServerHandler", new HttpServerHandler());


    }
}
